/*
 * @Description: 
 * @Author: 马爽
 * @Date: 2021-03-04 20:28:37
 * @LastEditTime: 2021-03-10 13:20:25
 * @LastEditors: 马爽
 */

import { request } from 'umi';
import { AddUserType, UpdateUsers, AddIdentityType, AddAuthorityApi, AuthorityView, SetIdentityApi, SetIdentityView } from '@/interface/user';

//展示用户数据
export const getUser = () => {
    return request('/user/user',{method:'GET'})
}

//展示身份数据
export const getIdentity = () => {
    return request('/user/identity',{method:'GET'})
}

//展示api接口权限数据
export const getApiAuthority = () => {
    return request('/user/api_authority',{method:'GET'})
}

//展示身份和api权限关系
export const getIdentityApi = () => {
    return request('/user/identity_api_authority_relation',{method:'GET'})
}

//获取视图权限数据
export const view_authority = () => {
    return request('/user/view_authority',{method:'GET'})
}

//展示身份和视图权限关系
export const getIdentityView = () => {
    return request('/user/identity_view_authority_relation',{method:'GET'})
}

//添加用户
export const getAddUser = (data:AddUserType) => {
    return request('/user',{method:'POST',data})
}

//添加身份
export const addIdentity = (data:AddIdentityType) => {
    return request('/user/identity/edit',{method:'GET',params:data })
}

//更新用户信息(用户名，用户密码，用户身份)
export const updateUsers = (data:UpdateUsers) => {
    return request('/user/user',{method:'PUT',data})
}

//添加视图权限  
export const authorityView = (data:AuthorityView) => {
    return request('/user/authorityView/edit',{method:'GET',params:data })
}

//添加api接口权限
export const addAuthorityApi = (data:AddAuthorityApi) => {
    return request('/user/authorityApi/edit',{method:'GET',params:data})
}

//给身份设定api接口权限
export const setIdentityApi = (data:SetIdentityApi) => {
    return request('/user/setIdentityApi',{method:'POST',data})
}

//给身份设定视图权限
export const setIdentityView = (data:SetIdentityView) => {
    return request('/user/setIdentityView',{method:'POST',data})
}